package mobi.greenplate.theweb.bootstrap;

import java.util.Date;
import mobi.greenplate.theweb.domain.Address;
import mobi.greenplate.theweb.domain.Community;
import mobi.greenplate.theweb.domain.Friend;
import mobi.greenplate.theweb.domain.Location;
import mobi.greenplate.theweb.domain.OfferRide;
import mobi.greenplate.theweb.domain.RepeatType;
import mobi.greenplate.theweb.domain.RequestRide;
import mobi.greenplate.theweb.domain.RideState;
import mobi.greenplate.theweb.domain.Transport;
import mobi.greenplate.theweb.domain.TransportType;
import mobi.greenplate.theweb.domain.User;
import mobi.greenplate.theweb.domain.UserDetail;
import mobi.greenplate.theweb.domain.UserRole;
import mobi.greenplate.theweb.domain.UserType;

/**
 *
 * @author dmakariev
 */
public class BootstrapDomainFactory {

    public static User newUser(String username, String password){
        User user = new User(username,password);
        user.setType(UserType.agency);
        user.setUserRole(UserRole.ROLE_USER);
        return user;
    }


    public static UserDetail newUserDetail(User owner){
        UserDetail userDetail = new UserDetail();
        userDetail.setEmail("testuser@mailinator.com");
        userDetail.setFirstName("testFirst");
        userDetail.setLastName("testLast");
        userDetail.setOwner(owner);
        userDetail.setPhone("666445656");
        userDetail.setType(UserType.individual);
        return userDetail;
    }

    public static Address newAddress_1(){
        Address address = new Address();
        address.setCity("San Francisco");
        address.setLatitude(25);
        address.setLongtitude(52);
        address.setState("CA");
        address.setStreet("Mission");
        address.setZip("94103");
        return address;
    }

    public static Address newAddress_2(){
        Address address = new Address();
        address.setCity("Mountain View");
        address.setLatitude(44);
        address.setLongtitude(66);
        address.setState("CA");
        address.setStreet("Castro");
        address.setZip("94043");
        return address;
    }

    public static Community newCommunity(User owner){
        Community community = new Community();
        community.setGroupName("my group");
        community.setOwner(owner);
        return community;
    }

    public static Friend newFriend(User owner,Community community){
        Friend friend = new Friend();
        friend.setOwner(owner);
        friend.setUserName("someFriend");
        friend.setCommunity(community);
        return friend;
    }

    public static Location newLocation(User owner, Address address){
        Location location = new Location();
        location.setAddress(address);
        location.setOwner(owner);
        location.setLocationName("some location");
        return location;
    }

    public static OfferRide newOfferRide(User offeredBy, Address endAddress, Address startAddress, Transport transportWith){
        OfferRide offerRide = new OfferRide();
        offerRide.setDescription("offerRide description");
        offerRide.setEndAddress(endAddress);
        offerRide.setStartAddress(startAddress);
        offerRide.setRepeatType(RepeatType.none);
        offerRide.setRideState(RideState.opened);
        offerRide.setTransportWith(transportWith);
        offerRide.setStartTime(new Date(2010, 9, 20));
        offerRide.setOfferedBy(offeredBy);
        return offerRide;
    }

    public static RequestRide newRequestRide(User requester, Address endAddress, Address startAddress){
        RequestRide requestRide = new RequestRide();
        requestRide.setRequester(requester);
        requestRide.setEndAddress(endAddress);
        requestRide.setRideState(RideState.opened);
        requestRide.setStartAddress(startAddress);
        requestRide.setStartTime(new Date(2010,9,21));
        return requestRide;
    }

    public static Transport newTransport(User owner){
        Transport transport = new Transport();
        transport.setOwner(owner);
        transport.setTransportDescription("transport description");
        transport.setTransportName("transport name");
        transport.setType(TransportType.bus);
        return transport;
    }

}
